<template>
  <div class="detail-enterprise">
    <header class="add-header">
      <el-page-header content="查看企业" @back="$router.back()" />
    </header>
    <main class="add-main">
      <div class="form-container">
        <div class="title">企业信息</div>
        <el-descriptions :column="2" class="form table-container table-descriptions">
          <el-descriptions-item label-class-name="font" label="企业名称"><div>{{ enterPriseList.businessLicenseName }}</div></el-descriptions-item>
          <el-descriptions-item label-class-name="font" label="法人"><div>{{ enterPriseList.legalPerson }}</div></el-descriptions-item>
          <el-descriptions-item label-class-name="font" label="注册地址"><div>{{ enterPriseList.registeredAddress }}</div></el-descriptions-item>
          <el-descriptions-item label-class-name="font" label="所在行业"><div>{{ enterPriseList.industryName }}</div></el-descriptions-item>
          <el-descriptions-item label-class-name="font" label="营业执照"><div><img class="img" :src="enterPriseList.businessLicenseUrl" alt=""></div></el-descriptions-item>
        </el-descriptions>
        <div class="BackGroungGray" />
        <div class="title">联系人信息</div>
        <el-descriptions :column="2" class="form table-container table-descriptions">
          <el-descriptions-item label-class-name="font" label="企业联系人"><div>{{ enterPriseList.contact }}</div></el-descriptions-item>
          <el-descriptions-item label-class-name="font" label="联系电话"><div>{{ enterPriseList.contactNumber }}</div></el-descriptions-item>
        </el-descriptions>
        <div class="BackGroungGray" />
        <div class="title">租赁记录</div>
        <div class="table-container">
          <el-table
            :data="rentList"
            style="width: 100%"
            border
          >
            <el-table-column
              prop="index"
              label="序号"
              width="50"
              type="index"
            />
            <el-table-column
              prop="name"
              label="租赁楼宇"
              width="180"
            />
            <el-table-column
              label="租赁起止时间"
              width="280"
            >
              <template #default="{row}">
                {{ row.startTime }} - {{ row.endTime }}
              </template>
            </el-table-column>
            <el-table-column
              label="租赁合同(点击预览)"
            >
              <template #default="{row}">
                <a :href="`${url}${row.contractUrl}`" target="_blank">
                  <el-button type="text">
                    {{ row.contractName }}
                  </el-button>
                </a>
              </template>
            </el-table-column>
            <el-table-column
              prop="createTime"
              label="录入时间"
            />
            <el-table-column
              prop="address"
              label="操作"
            >
              <template #default="{row}">
                <a :href="row.contractUrl">
                  <el-button type="text">合同下载</el-button>
                </a>
              </template>
            </el-table-column>
          </el-table>
        </div>

      </div>
    </main>

  </div>
</template>

<script>
import { getEnterpriseDetailAPI } from '@/api/park'
export default {
  data() {
    return {
      enterPriseList: [],
      rentList: [],
      url: 'https://view.officeapps.live.com/op/view.aspx?src='
    }
  },
  computed: {
    id() {
      return this.$route.query.id
    }
  },
  // 判断是否有id，如果有调用接口
  created() {
    if (this.$route.query.id) {
      this.getEnterpriseDetail()
    }
  },
  methods: {
    async getEnterpriseDetail() {
      const res = await getEnterpriseDetailAPI(this.id)
      this.rentList = res.data.rent
      this.enterPriseList = res.data
    }
  }
}
</script>

<style scoped lang="scss">
.detail-enterprise {
  background-color: #f4f6f8;
  height: 100vh;

  .add-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;

    .left {
      span {
        margin-right: 4px;
      }
      .arrow{
        cursor: pointer;
      }
    }

    .right {
      text-align: right;
    }
  }

  .add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;
      margin-bottom: 20px;
      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }
    }
    .table-container{
      padding:20px;
    }
    .preview{
      img{
        width: 100px;
      }
    }
  }
}
.table-descriptions{
    margin-left: 200px;
}
::v-deep .font{
    padding:10px;
}
.table-descriptions div {
    font-weight: 500;
    color: black;
    font-family: '微软雅黑';
    line-height: 35px;
    font-size: 18px;
}
.form {
    margin-bottom: 20px;
    padding: 20px 65px 24px
}
.img {
  /* 避免拉伸变形，宽高自适应容器 */
  width: 50%;
  height: auto;
  /* 柔和圆角，让边角不生硬 */
  border-radius: 8px;
  /* 加层 subtle 阴影，立体但不夸张 */
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  /* 过渡动画，让hover效果更丝滑 */
  transition: all 0.3s ease;
  /* 隐藏溢出内容（配合圆角裁剪） */
  overflow: hidden;
  /* 让图片作为块级元素，消除底部空隙 */
  display: block;
}

/* 悬停时轻微放大 + 阴影增强，提升交互感 */
.img:hover {
  /* 轻微放大，突出交互 */
  transform: scale(1.03);
  /* 阴影更明显，强化悬浮感 */
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.BackGroungGray{
    height: 30px;
    opacity: 0.1;
    width: 100%;
    background-color: gray;
}
</style>
